import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { environment } from 'projects/xmly/src/environments/environment';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { Base, User } from './types';
interface LoginType {
  user:User,
  token:string
}
@Injectable({
  providedIn: 'root',
})
export class UserService {
  readonly prefix = '/xmly/';
  constructor(private http: HttpClient) {}
  login(params:Exclude<User, 'name'>): Observable<LoginType> { 
    return this.http
      .post(`${environment.baseUrl}${this.prefix}login`, params)
      .pipe(map((res: Base<LoginType>) => res.data));
  }
}
